class Links:
    def __init__(self, list = []):
        self.links = list
        
    def append(self, link):
        self.links.append(link)
        
    def filter_by_tag(self, tag):
        return DeliciousLinks([link for link in self.links if tag in link.tags])

    def filter_by_start_date(self, start_date):
        return DeliciousLinks([link for link in self.links if link.datetime > start_date])

    def filter_by_end_date(self, end_date):
        return DeliciousLinks([link for link in self.links if link.datetime < end_date])
        
    def group_by_tag(self):
        result = {}
        for link in self.links:
            for tag in link.tags:
                if not tag in result: result[tag] = []
                result[tag].append(link)
        return result
        
    def show(self):
        for link in self.links:
            print link.show().encode("UTF-8")    
